<?php
/**
 * YouNet
 *
 * @category   Application_Extensions
 * @package    Groupbuy
 * @copyright  Copyright 2011 YouNet Company
 * @license    http://www.modules2buy.com/
 * @version    $Id: AdminSettingsController.php
 * @author     Minh Nguyen
 */
class Advmenusystem_AdminSettingsController extends Core_Controller_Action_Admin
{
  public function init()
  {
    $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')
      ->getNavigation('advmenusystem_admin_main', array(), 'advmenusystem_admin_main_settings');
  }
  public function indexAction()
  {
    $this->view->form = $form = new Advmenusystem_Form_Admin_Global();
   if( $this->getRequest()->isPost() && $form->isValid($this->_getAllParams()) )
    {
      $values = $form->getValues();
      foreach ($values as $key => $value){
        if($value < 0)
            $value = 0;
        Engine_Api::_()->getApi('settings', 'core')->setSetting($key, round($value,2));
      }
     $form->addNotice('Your changes have been saved.');
	 $this->_redirect('/admin/advmenusystem/settings');
    }
  }
}
